package cn.leaf.controller;

import cn.leaf.entity.StarEntity;
import cn.leaf.service.DubboConsumerService;
import com.google.common.collect.Lists;
import lombok.RequiredArgsConstructor;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;

/**
 *
 * description: test dubbo api controller
 *
 * @author Cyril
 * @version v1.0.0
 * @since 2021-05-24 23:39:08
 *
 */
@RestController
@RequestMapping(value = "dubbo")
@RequiredArgsConstructor
public class DubboConsumerController {

    private final DubboConsumerService consumerService;

    @GetMapping
    public String hello() {
        RpcContext.getContext().setAttachment("token", "1");
        return consumerService.helloDubbo();
    }

    @GetMapping(value = "star-info")
    public StarEntity starInfo() {
        return consumerService.starInfo();
    }
}
